import React, { useMemo } from "react";
import { useNavigate, useLocation } from "react-router-dom";
import { NavBar, Space, Toast } from "antd-mobile";
import { routes } from "../../router";
import { SearchOutline, MoreOutline, CloseOutline } from "antd-mobile-icons";

const Top = () => {
  const location = useLocation();
  const navigate = useNavigate();
  const back = () => {
    navigate("/");
    navigate(0);
  };
  const title = useMemo(
    () => routes.find((item: any) => item.path == location.pathname)?.title,
    [location.pathname]
  );

  return (
    <div className="top">
      <NavBar onBack={back}>{title}</NavBar>
    </div>
  );
};
export default Top;
